﻿/*******************************************************************************
 * Copyright © 2017 FriendStar.Framework 版权所有
 * Author: FZH
 * Description: FriendStar快速开发平台
 * Website：http://www.FriendStar.cn
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using SqlSugarRepository;
using FriendStar.Code;
using FriendStar.Domain.Entity.MainData;
using FriendStar.Domain.IRepository.MainData;
using FriendStar.Repository.MainData;

namespace FriendStar.Application.MainData
{
    /// <summary>
	/// 数据视图 V_ZSJ_12_GH_SuProduction 对应的数据应用功能类。
	/// </summary>
	public class V_ZSJ_12_GH_SuProductionApp
    {       
        private string UseUnit = Configs.GetValue("UseUnit");  

        private IV_ZSJ_12_GH_SuProductionRepository service = new V_ZSJ_12_GH_SuProductionRepository();

        public List<V_ZSJ_12_GH_SuProductionEntity> GetList(Pagination pagination, string Production, string FProCompanyNO, string ProductionTypeNO)
        {
            var expression = ExtLinq.True<V_ZSJ_12_GH_SuProductionEntity>();
            expression = expression.And(t => t.UseUnit == UseUnit);
            if (!string.IsNullOrEmpty(Production))
            {
                expression = expression.And(t => t.FProductionNO.Contains(Production) || t.FProductionName.Contains(Production));
            }
            if (!string.IsNullOrEmpty(FProCompanyNO))
            {
                expression = expression.And(t => t.FProCompanyNO == FProCompanyNO);
            }
            if (!string.IsNullOrEmpty(ProductionTypeNO))
            {
                expression = expression.And(t => t.FProductionTypeNO == ProductionTypeNO);
            }
            return service.FindList(expression, pagination);
        }

        public V_ZSJ_12_GH_SuProductionEntity GetForm(string keyValue)
        {
            var expression = ExtLinq.True<V_ZSJ_12_GH_SuProductionEntity>();
            expression = expression.And(t => t.ProductionID == keyValue);
            return service.FindEntity(expression);
        }
    }
}